import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/case_invoice_entity.dart';

CaseInvoiceEntity $CaseInvoiceEntityFromJson(Map<String, dynamic> json) {
  final CaseInvoiceEntity caseInvoiceEntity = CaseInvoiceEntity();
  final String? cargo = jsonConvert.convert<String>(json['cargo']);
  if (cargo != null) {
    caseInvoiceEntity.cargo = cargo;
  }
  final String? showTab = jsonConvert.convert<String>(json['showTab']);
  if (showTab != null) {
    caseInvoiceEntity.showTab = showTab;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    caseInvoiceEntity.email = email;
  }
  final List<
      CaseInvoiceRelateCases>? relateCases = (json['relateCases'] as List<
      dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<CaseInvoiceRelateCases>(e) as CaseInvoiceRelateCases)
      .toList();
  if (relateCases != null) {
    caseInvoiceEntity.relateCases = relateCases;
  }
  final String? taxid = jsonConvert.convert<String>(json['taxid']);
  if (taxid != null) {
    caseInvoiceEntity.taxid = taxid;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    caseInvoiceEntity.remark = remark;
  }
  final CaseInvoiceHistoryInvoice? historyInvoice = jsonConvert.convert<
      CaseInvoiceHistoryInvoice>(json['historyInvoice']);
  if (historyInvoice != null) {
    caseInvoiceEntity.historyInvoice = historyInvoice;
  }
  return caseInvoiceEntity;
}

Map<String, dynamic> $CaseInvoiceEntityToJson(CaseInvoiceEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['cargo'] = entity.cargo;
  data['showTab'] = entity.showTab;
  data['email'] = entity.email;
  data['relateCases'] = entity.relateCases?.map((v) => v.toJson()).toList();
  data['taxid'] = entity.taxid;
  data['remark'] = entity.remark;
  data['historyInvoice'] = entity.historyInvoice?.toJson();
  return data;
}

extension CaseInvoiceEntityExtension on CaseInvoiceEntity {
  CaseInvoiceEntity copyWith({
    String? cargo,
    String? showTab,
    String? email,
    List<CaseInvoiceRelateCases>? relateCases,
    String? taxid,
    String? remark,
    CaseInvoiceHistoryInvoice? historyInvoice,
  }) {
    return CaseInvoiceEntity()
      ..cargo = cargo ?? this.cargo
      ..showTab = showTab ?? this.showTab
      ..email = email ?? this.email
      ..relateCases = relateCases ?? this.relateCases
      ..taxid = taxid ?? this.taxid
      ..remark = remark ?? this.remark
      ..historyInvoice = historyInvoice ?? this.historyInvoice;
  }
}

CaseInvoiceRelateCases $CaseInvoiceRelateCasesFromJson(
    Map<String, dynamic> json) {
  final CaseInvoiceRelateCases caseInvoiceRelateCases = CaseInvoiceRelateCases();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    caseInvoiceRelateCases.caseId = caseId;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    caseInvoiceRelateCases.caseName = caseName;
  }
  return caseInvoiceRelateCases;
}

Map<String, dynamic> $CaseInvoiceRelateCasesToJson(
    CaseInvoiceRelateCases entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['caseName'] = entity.caseName;
  return data;
}

extension CaseInvoiceRelateCasesExtension on CaseInvoiceRelateCases {
  CaseInvoiceRelateCases copyWith({
    String? caseId,
    String? caseName,
  }) {
    return CaseInvoiceRelateCases()
      ..caseId = caseId ?? this.caseId
      ..caseName = caseName ?? this.caseName;
  }
}

CaseInvoiceHistoryInvoice $CaseInvoiceHistoryInvoiceFromJson(
    Map<String, dynamic> json) {
  final CaseInvoiceHistoryInvoice caseInvoiceHistoryInvoice = CaseInvoiceHistoryInvoice();
  final String? cargo = jsonConvert.convert<String>(json['cargo']);
  if (cargo != null) {
    caseInvoiceHistoryInvoice.cargo = cargo;
  }
  final String? showTab = jsonConvert.convert<String>(json['showTab']);
  if (showTab != null) {
    caseInvoiceHistoryInvoice.showTab = showTab;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    caseInvoiceHistoryInvoice.email = email;
  }
  final List<
      CaseInvoiceHistoryInvoiceRelateCases>? relateCases = (json['relateCases'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<CaseInvoiceHistoryInvoiceRelateCases>(
          e) as CaseInvoiceHistoryInvoiceRelateCases).toList();
  if (relateCases != null) {
    caseInvoiceHistoryInvoice.relateCases = relateCases;
  }
  return caseInvoiceHistoryInvoice;
}

Map<String, dynamic> $CaseInvoiceHistoryInvoiceToJson(
    CaseInvoiceHistoryInvoice entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['cargo'] = entity.cargo;
  data['showTab'] = entity.showTab;
  data['email'] = entity.email;
  data['relateCases'] = entity.relateCases?.map((v) => v.toJson()).toList();
  return data;
}

extension CaseInvoiceHistoryInvoiceExtension on CaseInvoiceHistoryInvoice {
  CaseInvoiceHistoryInvoice copyWith({
    String? cargo,
    String? showTab,
    String? email,
    List<CaseInvoiceHistoryInvoiceRelateCases>? relateCases,
  }) {
    return CaseInvoiceHistoryInvoice()
      ..cargo = cargo ?? this.cargo
      ..showTab = showTab ?? this.showTab
      ..email = email ?? this.email
      ..relateCases = relateCases ?? this.relateCases;
  }
}

CaseInvoiceHistoryInvoiceRelateCases $CaseInvoiceHistoryInvoiceRelateCasesFromJson(
    Map<String, dynamic> json) {
  final CaseInvoiceHistoryInvoiceRelateCases caseInvoiceHistoryInvoiceRelateCases = CaseInvoiceHistoryInvoiceRelateCases();
  final String? caseId = jsonConvert.convert<String>(json['caseId']);
  if (caseId != null) {
    caseInvoiceHistoryInvoiceRelateCases.caseId = caseId;
  }
  final String? caseName = jsonConvert.convert<String>(json['caseName']);
  if (caseName != null) {
    caseInvoiceHistoryInvoiceRelateCases.caseName = caseName;
  }
  return caseInvoiceHistoryInvoiceRelateCases;
}

Map<String, dynamic> $CaseInvoiceHistoryInvoiceRelateCasesToJson(
    CaseInvoiceHistoryInvoiceRelateCases entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['caseId'] = entity.caseId;
  data['caseName'] = entity.caseName;
  return data;
}

extension CaseInvoiceHistoryInvoiceRelateCasesExtension on CaseInvoiceHistoryInvoiceRelateCases {
  CaseInvoiceHistoryInvoiceRelateCases copyWith({
    String? caseId,
    String? caseName,
  }) {
    return CaseInvoiceHistoryInvoiceRelateCases()
      ..caseId = caseId ?? this.caseId
      ..caseName = caseName ?? this.caseName;
  }
}